#!/bin/bash

/usr/bin/expect << EOF

set timeout -1

spawn scp -P $2 $6/$5 $3@$1:$7

expect {
  "password:" {
    send "$4\r"
  }
  "(yes/no)?" {
    send "yes\r"
    expect "password:"
    send "$4\r"
  }
  "lost connection" {
    exit 1
  }
}

expect "100%"
expect eof
exit

EOF
